package ru.spbu.math.android.cbrf.view;

import java.util.ArrayList;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

public class AppWidgetConfigure{

	private static final String TAG = "App Widget Configure";
	
	private static final String PREFS_NAME = "ru.spbu.math.android.cbrf.view.AppWidgetProvider";
	private static final String PREF_PREFIX_KEY = "prefix_";

	static void saveTitlePref(Context context, int appWidgetId, String appItemId) {
        SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit();
        prefs.putInt(PREF_PREFIX_KEY + appWidgetId, appWidgetId);
        prefs.putString(PREF_PREFIX_KEY + appWidgetId, appItemId);
        prefs.commit();
        Log.d(TAG, "appWidgetId = " + appWidgetId);
        Log.d(TAG, "appItemId = " + appItemId);
    }
	
	static String loadTitlePref(Context context, int appWidgetId) {
        SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, 0);
//        int prefix = prefs.getInt(PREF_PREFIX_KEY + appWidgetId, 0);
        return prefs.getString(PREF_PREFIX_KEY + appWidgetId, null);
    }
	
	static void deleteTitlePref(Context context, int appWidgetId){
		SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit();
		prefs.remove(PREF_PREFIX_KEY + appWidgetId);
		prefs.commit();
	}
	
	//TODO: create if this method is needed
	static void loadAllTitlePrefs(Context context, ArrayList<Integer> appWidgetIds,
            ArrayList<String> texts) {
    }



}
